import React from 'react'
import cookie from 'react-cookies'


const AuthRouter = (props) =>
{
  //说明判断是否要登录
  if(props.auth)
  {

    // 获取LoginUser load => 获取cookie名称的值
    var LoginUser = cookie.load('LoginUser') ? cookie.load('LoginUser') : {}

    if(JSON.stringify(LoginUser) === "{}")
    {
      return (
        // eslint-disable-next-line react/jsx-pascal-case
        <React.$router.Navigate to="/user/base/login" />
      )
    }else
    {
      return (
        <>
          {props.component}
        </>
      )
    }
  }else
  {
    return (
      <>
        {props.component}
      </>
    )
  }
}

export default AuthRouter